<script type="text/javascript">
	selectTab('link_submit_entry');
    var msg_notice = '<?php echo $this->translate("MSG_NOTICE"); ?>'
    
    function showPopUpDialog(options)
    {
        Social.getDialog().create({
            'title'     : msg_notice,
            'content'   : options.content,
            'buttons'	: {
                "OK": function(){
                    $(this).dialog("close");
                }
            }
        });
    }
        
	$(document).ready(function(){
		/*
		var userinfo	= getcookie('userinfo');
		if( userinfo )
		{
			userinfo		= base64_decode(userinfo);
			var arrInfo		= $.parseJSON(userinfo);
			for(i in arrInfo)
			{
				if( arrInfo[i] )
				{
					$(".submit_form").find("[data-field='" + i +"']").val(arrInfo[i]);
				}
			}			
		}
		*/
		<?php if(!empty($this->index_dob)):?>
			$('input[name="candidate[<?php echo $this->index_dob;?>]"]').datepicker({
				dateFormat: '<?php echo BIRTHDAY_FORMAT_JS; ?>',
				yearRange: "-50:+0",
				changeMonth: true,
				changeYear: true
			});
		<?php endif;?>
		<?php if(!empty($this->is_not_allow_to_submit)):?>
			$('input, select, textarea').attr('disabled', 'disabled');
			$('input[type=submit]').removeAttr('disabled');//for IE text color
			$('input[type=submit]').click(function(){ return false;});
		<?php else:?>
			$('form#entry_form').submit(function(){
				$('input[type=submit]').attr('disabled', 'disabled');
				$('button#reset').attr('disabled', 'disabled');
				if($.trim($('#image').val())=='')
				{
					showPopUpDialog({
                        'title': msg_notice,
                        'content': '<?php echo $this->translate('ERROR_EMPTY_IMAGE');?>'
                    });
					$('#image').focus();
					$('input[type=submit]').attr('disabled', false);
					$('button#reset').attr('disabled', false);
					return false;
				}
				if($.trim($('#title').val())=='')
				{
					showPopUpDialog({
                        'title': msg_notice,
                        'content': '<?php echo $this->translate('ERROR_EMPTY_TITLE');?>'
                    });
					$('#title').focus();
					$('input[type=submit]').attr('disabled', false);
					$('button#reset').attr('disabled', false);
					return false;
				}
				if($('#title').val().length>255)
				{
					showPopUpDialog({
                        'title': msg_notice,
                        'content': '<?php echo $this->translate('ERROR_EXCEED_MAXLENGTH_TITLE');?>'
                    });
					$('#title').focus();
					$('input[type=submit]').attr('disabled', false);
					$('button#reset').attr('disabled', false);
					return false;
				}
                if($('#description').val().length>1000)
				{
					showPopUpDialog({
                        'title': msg_notice,
                        'content': '<?php echo $this->translate('ERROR_EXCEED_MAXLENGTH_DESCRIPTION');?>'
                    });
					$('#description').focus();
					$('input[type=submit]').attr('disabled', false);
					$('button#reset').attr('disabled', false);
					return false;
				}
				<?php
				if(!empty($this->validate_script)):
					echo $this->validate_script;
				endif;
				?>
			});
		<?php endif;?>
		$('#show_terms_and_conditions').click(function(e){
			e.preventDefault();
			var title = "<?php echo $this->translate('LABEL_TERMS_AND_CONDITIONS');?>";
			var message = '<?php echo $this->terms;?>';
			var content = message;
			var dialog = Social.getDialog().create({
				title: title,
				content: content,
				buttons:{
					Ok: function(){
						$(this).dialog("close");
					}
				}
			});
		});
	});
</script>
<?php if(isset($this->message)): ?>
    <div class="sm_message_panel">
        <p class="header"><?php echo $this->message; ?></p>
    </div>
<?php endif; ?>
<div class="submit_form">
	<div class="form_detail">
		<?php echo $this->form; ?>
	</div>
</div>


<?php echo $this->partial('index/scrollTop.phtml'); ?>